package com.hxgis.common.conare;

import com.hxgis.common.entity.RainstormFeatureInfo;

import java.util.List;

/**
 * 多个站点暴雨过程的时间计算
 */
public class RainFeatureTime {

    private Long startTime;

    private Long endTime;

    private String stationNo;

    private List<RainstormFeatureInfo> rainstormFeatureInfos;

    /**
     * 区域标识
     */
    private String areaFlag;

    public RainFeatureTime(List<RainstormFeatureInfo> rainstormInfos) {
        this.rainstormFeatureInfos = rainstormInfos;
        rainstormInfos.sort((o1, o2) -> {
            return (int) (o1.getTime()-o2.getTime());
        });
        stationNo = rainstormInfos.get(0).getStationNo();
        startTime = rainstormInfos.get(0).getTime();
        endTime = rainstormInfos.get(rainstormInfos.size()-1).getTime();
    }


    public boolean checkTime(RainFeatureTime rainstormTime){
        Long startTime = rainstormTime.getStartTime();
        Long endTime = rainstormTime.getEndTime();
        //包含
        if (startTime>=this.startTime && endTime<=this.endTime){
            return true;
        }
        //包含
        if (startTime<= this.startTime && endTime>=this.endTime){
            return true;
        }

        if (endTime>=this.endTime && startTime>=this.startTime && startTime<=this.endTime){
            return true;
        }

        if (startTime<=this.startTime && endTime>=this.startTime && endTime<=this.endTime){
            return true;
        }


        return false;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public List<RainstormFeatureInfo> getRainstormInfos() {
        return rainstormFeatureInfos;
    }

    public void setRainstormInfos(List<RainstormFeatureInfo> rainstormInfos) {
        this.rainstormFeatureInfos = rainstormInfos;
    }

    public String getAreaFlag() {
        return areaFlag;
    }

    public void setAreaFlag(String areaFlag) {
        this.areaFlag = areaFlag;
    }

    public String getStationNo() {
        return stationNo;
    }

    public void setStationNo(String stationNo) {
        this.stationNo = stationNo;
    }
}
